package comparator;
import util.*;
import java.util.Map;
import java.util.Date;
import java.util.HashMap;
import java.util.Comparator;

/**
 * @author JFM
 */
public class ComparatorFechasEntrega implements Comparator
	{
	public int compare(Object o1, Object o2)
		{
		if(o1 instanceof HashMap && o2 instanceof HashMap)
			{
			Date f1 = Util.parseDate( (String)((Map)o1).get("fechaInicio") );
			Date f2 = Util.parseDate( (String)((Map)o2).get("fechaInicio") );
			long res = f1.getTime() - f2.getTime();

			if(res < 0) return -1;
			if(res > 0) return 1;
			return 0;
			}
		return 1;
		}

	@Override
	public boolean equals(Object o)
		{ return o instanceof ComparatorFechasEntrega; }

	@Override
	public int hashCode()
		{
		int hash = 5;
		return hash;
		}
	}
